package cn.gok.springboot.controller;

import cn.gok.springboot.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.websocket.server.PathParam;


/**
 * @ClassName UserController
 * @Description TODO
 * @Author HP
 * @Date 19:19 2022/7/14
 * @Version 1.0
 **/
@Controller("/user")
public class UserController {
    private static int SUXXESS=1;
    private static int NOSUXXESS=2;
    private static int REG=0;

    @Autowired
    private User user;

    @RequestMapping("/")
    public String init(){
        return "login";
    }

    @ResponseBody
    @RequestMapping("/login")
    public int login(@PathParam("name") String name, @PathParam("password") String password){
        if(user.getName().equals(name)){
            if(user.getPassword().equals(password)){
                return SUXXESS;
            }
            return NOSUXXESS;
        }
        return REG;
    }

    @RequestMapping("/registered")
    public static String success(){
//        注册
        return "registered";
    }

}
